package o;

import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnKeyListener;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListAdapter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AlertController;
import androidx.appcompat.app.AlertController.a;
import o.ah.c;

public class af extends ag implements DialogInterface {
    final AlertController ˋ = new AlertController(getContext(), this, getWindow());

    public static class d {
        private final int ˋ;
        private final a ˎ;

        public d(@NonNull Context context) {
            this(context, af.ˊ(context, 0));
        }

        public d(@NonNull Context context, @StyleRes int i) {
            this.ˎ = new a(new ContextThemeWrapper(context, af.ˊ(context, i)));
            this.ˋ = i;
        }

        @NonNull
        public Context ˎ() {
            return this.ˎ.ˏ;
        }

        public d ॱ(@Nullable CharSequence charSequence) {
            this.ˎ.ॱॱ = charSequence;
            return this;
        }

        public d ˏ(@Nullable View view) {
            this.ˎ.ʽ = view;
            return this;
        }

        public d ˊ(@Nullable Drawable drawable) {
            this.ˎ.ˎ = drawable;
            return this;
        }

        public d ˎ(OnKeyListener onKeyListener) {
            this.ˎ.ʼॱ = onKeyListener;
            return this;
        }

        public d ˊ(ListAdapter listAdapter, OnClickListener onClickListener) {
            this.ˎ.ʾ = listAdapter;
            this.ˎ.ʽॱ = onClickListener;
            return this;
        }

        public af ˋ() {
            af afVar = new af(this.ˎ.ˏ, this.ˋ);
            this.ˎ.ˎ(afVar.ˋ);
            afVar.setCancelable(this.ˎ.ॱˎ);
            if (this.ˎ.ॱˎ) {
                afVar.setCanceledOnTouchOutside(true);
            }
            afVar.setOnCancelListener(this.ˎ.ʻॱ);
            afVar.setOnDismissListener(this.ˎ.ᐝॱ);
            if (this.ˎ.ʼॱ != null) {
                afVar.setOnKeyListener(this.ˎ.ʼॱ);
            }
            return afVar;
        }
    }

    protected af(@NonNull Context context, @StyleRes int i) {
        super(context, ˊ(context, i));
    }

    static int ˊ(@NonNull Context context, @StyleRes int i) {
        if (((i >>> 24) & 255) >= 1) {
            return i;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(c.ʻॱ, typedValue, true);
        return typedValue.resourceId;
    }

    public void setTitle(CharSequence charSequence) {
        super.setTitle(charSequence);
        this.ˋ.ˏ(charSequence);
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.ˋ.ˏ();
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (this.ˋ.ˊ(i, keyEvent)) {
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        if (this.ˋ.ˏ(i, keyEvent)) {
            return true;
        }
        return super.onKeyUp(i, keyEvent);
    }
}
